Preliminary

Let us follow up on the task 1, where we briefly explored the data set WAIS. It contains information about the results of 4 subsets of the Wechsler Adult Intelligence Scale for people divided into two groups depending on whether or not do they present a senile factor. Let us recall the figure from task 1 which suggests a notable difference in performance between the two groups.

Hotelling test

We will further examine the difference by performing a two sample Hotelling’s test on the difference of the vectors of means. We will consider that the data for group 1 (non-senile) is a sample \(X_1, \dots, X_{n_x} \sim \mathcal{N}_p(\mu_x,\Sigma)\) and the data for group 2 (senile) is a sample \(Y_1, \dots, Y_{n_y} \sim \mathcal{N}_p(\mu_y,\Sigma)\). We will test the null hypothesis that \[\begin{align*} H_0: \mu_x = \mu_y & &\text{against} & & H_1: \exists i \text{ such that }\mu_{x,i} \neq \mu_{y,i} \end{align*}\] The hotelling test statistic is defined as \[ \frac{n_xn_y(n_x+n_y-p-1)}{p(n_x+n_y)^2}(\overline{\mathbf{X}}_{n_{x}} - \overline{\mathbf{Y}}_{n_{y}} )^TS^{-1} (\overline{\mathbf{X}}_{n_{x}} - \overline{\mathbf{Y}}_{n_{y}} ),\] where \(S = \frac{1}{n_x+n_y}(n_xS_x+n_yS_y)\) and \(p\) is the dimension of the data. The test statistic has under \(H_0\) F-distribution with \(p\) and \((n_x+n_y-p-1)\) degrees of freedom.

Asumption of equal variance matrices

Before we proceed to the test, let us comment on the assumption of equal variance matrices. The figure above suggests some problem with equal variances especially for the picture completion part. Also the rest of the variance matrices structure differs notably.

#X - non-senile, Y - senile
Sx = cov(X)
Sy = cov(Y)

round(Sx,2)
##              Information Similarities Arithmetic Pictures
## Information        11.47         9.09       6.38     2.07
## Similarities        9.09        12.09       5.94     0.54
## Arithmetic          6.38         5.94      11.09     1.79
## Pictures            2.07         0.54       1.79     3.69
round(Sy,2)
##              Information Similarities Arithmetic Pictures
## Information        10.57        10.45       9.68     7.66
## Similarities       10.45        18.24      12.09     8.91
## Arithmetic          9.68        12.09      13.18     5.32
## Pictures            7.66         8.91       5.32    12.75

Therefore we must be careful with a strict interpretation of the following results, since they might be a little off.

Test performance

Below we can see the results of the performed Hotelling’s test.

Hotel = hotelling.test(X,Y, var.equal = TRUE)
Hotel
## Test stat:  22.13 
## Numerator df:  4 
## Denominator df:  44 
## P-value:  0.001655

We can conclude that the means of the WAIS subtests differ significantly between the two groups. Therefore there is a relevant evidence that people without senile factor outperforms people with a present senile factor. An insight on which part of the WAIS subtest might be responsile for the difference can be obtained from the confidence intervals. We will use the simultaneous confidence intervals based on the fact that \[ P\left(\forall a \in \mathbb{R}^p: a^T\mu \in \, (a^T ( \overline{\mathbf{X}}_{n_{x}} - \overline{\mathbf{Y}}_{n_{y}} )\mp \sqrt{q_\alpha a^T S a} \,\right) = 1 -\alpha,\] where \(q_\alpha = \frac{p(n_x+n_y)^2}{n_xn_y(n_x+n_y-p-1)}F_{p,n_x + n_y -p -1} (1-\alpha)\).

mx = apply(X,2,mean)
my = apply(Y,2,mean)
Sx = cov(X)
Sy = cov(Y)
nx = nrow(X)
ny = nrow(Y)
alpha = 0.05
p = 4
S = 1/(nx+ny)*(nx*Sx+ny*Sy) 
m = mx-my
q = p*(nx+ny)^2/(nx*ny*(nx+ny-p-1))*qf(1-alpha, df1 = p, df2= nx+ny-p-1)

CIL = diag(p)%*%m - sqrt(q*diag(diag(p)%*%S%*%diag(p)))
CIU = diag(p)%*%m + sqrt(q*diag(diag(p)%*%S%*%diag(p)))
CIs = cbind(CIL,CIU,m)
colnames(CIs) = c('Lower','Upper','Mean')
round(CIs,3)
##               Lower Upper  Mean
## Information   0.037 7.598 3.818
## Similarities  0.079 8.389 4.234
## Arithmetic   -0.852 6.825 2.986
## Pictures      0.483 5.963 3.223

The corresponding intervals of all information, similarities and picture completion are to the right from zero, therefore all of them would reject the null hypothesis separately. The farthest one corresponds to the picture completion test, which is also considerably shorter. Here we must be careful since it is the variable which caused the biggest problem in the variance matrices.